export default class player extends Laya.Script {
    // 更多参数说明请访问: https://ldc2.layabox.com/doc/?nav=zh-as-2-4-0
    rig=null;
    big=null;
    Xr=0;
    ishand=false;
    owner=this.owner as Laya.Sprite;
    constructor() { super(); }
    
    onAwake(){
        Laya.stage.on("start",this,function(){
            this.owner.pos(432,692)
        })
        this.rig=this.owner.getComponent(Laya.RigidBody);
        this.big=this.owner.getComponent(Laya.BoxCollider);
        Laya.stage.on("hand",this,function(){this.ishand=true})
    }
    onTriggerEnter(other){
        if(other.label=="di"){
            Laya.stage.event("chu")
        }
        if(other.label=="foot"){
            this.owner.text="(`･ω･´)╭  ╮"
            this.big.height="100"
            Laya.stage.event("food")
        }
        if(other.label=="hand"){
            this.owner.text="╭(`･ω･´)╮╭  ╮"
            this.owner.width="240";
            Laya.stage.event("hand")
            
        }
        if(other.label=="zhu"){
            if(this.ishand){
                this.rig.linearVelocity={x:0,y:-100}
            }
        } 
        if(other.label=="zhu1"){
            this.rig.linearVelocity={x:0,y:-100}
        } 
       if(other.label=="AI"){
        Laya.stage.event("gamerover")
        }
    }
    onTriggerExit(other){
        if(other.label=="di"){
            Laya.stage.event("li")
        }
    }
    onUpdate(){
        if(this.owner.y>1103){
            Laya.stage.event("gamerover")
        }
    }
}